Hexo 优化设置

hexo官网

修改博客标题简介语言等

创建页面

编辑 _config.yml

1
2
3
4
5
6
7
8
9
10
# Site
title: Xxb
subtitle: Linux,crypto,mining
description:
keywords: Linux,crypto,mining
author: xxb.me
language:
- zh-CN
- zh-TW
- en


修改网站 URL 和链接格式

编辑 _config.yml

1
2
3
4
5
6
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://www.xxb.me
root: /
permalink: :category/:title/
permalink_defaults:

创建分类页

运行命令新建page页

1
hexo new page categories

编辑页面

1
2
3
4
5
6
7
8
9
10
11
12
---
title: 分类
date: 2018-04-25 22:34:08
type: "categories"
---


---
title: 标签
date: 2018-04-25 22:34:08
type: "tags"
---

实际使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
title: hexo 添加标签和分类
date: 2018-04-27 23:00:34
categories:
- hexo
tags:
- linux


---
layout: photo
title: My Gallery
date: 2019-06-19 15:54:13
# tags: [photo, 照片]
categories:
- hexo
tags:
- linux
- React
---


---
title: post title with whitespace
date: 2019-06-19 15:39:18
tags: [photo, 照片]
---

配置别名

其中: 以前的是正式的名称,以后的是访问的路径

1
2
3
4
5
6
7
8
9
10
11
12
13
# Category & Tag
default_category: uncategorized
category_map: hexo:hexo
ubuntu:ubuntu
computer vision:computer-vision
tag_map: linux:linux
ubuntu:ubuntu
vim:vim
tmux:tmux
hexo:hexo
yolo:yolo
opencv:opencv
computer vision:computer-vision

部署生效

一定要记得先clean在生成

1
2
3
$ hexo clean
$ hexo g
$ hexo d

运行后提示

1
INFO  Created: ~/Documents/code/blog/source/categories/index.md

找到 index.md 这个文件,为其添加 type 属性

1
2
3
4
5
---
title: tags
date: 2019-01-30 17:37:12
type: "categories"
---

修改主题 _config.yml 文件的menu段落,反注释掉tags那一行

1
2
3
4
5
6
7
8
9
menu:
home: / || home
about: /about/ || user
tags: /tags/ || tags
categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
#sitemap: /sitemap.xml || sitemap
#commonweal: /404/ || heartbeat

创建标签页

方法和创建分类页一样,只是把 categories 改为 tags

创建about页

参考创建标签页

添加诗词插件

今日诗词 API 根据不同地点、时间、节日、季节、天气、景观、城市、事件进行智能推荐,每次刷新都不同。
官网: https://www.jinrishici.com/
调用文档: https://www.jinrishici.com/doc/
在想放置诗词的地方添加以下代码:(我放在_partials/header/brand.swig)

1
2
<div id="jinrishici-sentence" class="shici"></div>
<script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>

自定义样式,修改主题样式文件source/css/_custom/custom.styl

1
.shici {font-size: 15px;text-align: center;font-weight: 300;color: #444;font-style: italic;}

在线演示: www.xxb.me

主题:https://github.com/ppoffice/hexo-theme-icarus

未完待续 …